package com.videri.match.client;

import com.google.gwt.user.client.ui.Composite;
/**
 * Modeled after the GWT sample KitchenSink, this abstract class
 * gives an outline for future implementations of the sink.  
 * @author Mike Bauer
 *
 */
public abstract class MatchSink extends Composite{
	
	/**
	 * This class will store info about a given implementation
	 * of a MatchSink.  It will also ensure that only one MatchSink
	 * of each type will ever be created.
	 * @author Michael Bauer
	 *
	 */
	public static abstract class MatchSinkInfo{
		private MatchSink instance;
		private String name;
		
		/**
		 * Assigns the sinks name
		 * @param name
		 */
		public MatchSinkInfo(String name){
			this.name=name;
		}
		
		/**
		 * This will create an instance of a MatchSink
		 * @return a new MatchSink
		 */
		public abstract MatchSink createInstance();
		
		/**
		 * This will return the current instance if it has
		 * already been instantiated otherwise it will
		 * return a new instantiation of the sink.
		 * @return either the current or a new MatchSink
		 */
		public final MatchSink getInstance(){
			if(instance!=null)
				return instance;
			return (instance = createInstance());
		}
		
		/**
		 * This will return the name of the MatchSink
		 * @return The name of the MatchSink
		 */
		public String getName(){
			return name;
		}	
		
		/**
		 * This will return the color of the MatchSink header
		 * @return The color of the MatchSink header in the form of a color
		 */
		public String getColor() {
			//This will get written over by each implemented version of a MatchSink
		    return "#2a8ebf";
	    }
	}
	
	/**
	 * This method will be called every time that the sink is told
	 * to remove itself from the main view panel.
	 */
	public void onHide(){
		
	}
	
	/**
	 * This method will be called every time that the sink is placed
	 * at the top of the main view panel.
	 */
	public void onShow(){
		
	}
}
